package com.ai.aicontact.execmgn.controller;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ai.aicontact.busi.entity.ExecFileLog;
import com.ai.aicontact.busi.entity.RedBlackList;
import com.ai.aicontact.busi.service.ExecFileLogService;
import com.ai.aicontact.common.vo.Grid;
import com.ai.aicontact.common.vo.PageFilter;

@Controller
@RequestMapping("/contactmgn/filelog")
public class ExecFileLogController {
	
	@Autowired
	ExecFileLogService execFileLogService;
	
	@RequestMapping("/{jspname}")
	public String web(@PathVariable("jspname") String jspname) {
		return "/contactmgn/filelog/" + jspname;
	}
	
	@InitBinder
	public void initBinder(ServletRequestDataBinder binder) {
		/**
		 * 自动转换日期类型的字段格式
		 */
		binder.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd"), true));
	}
	
	@ResponseBody
	@RequestMapping("queryExecFileLog")
	public Grid queryRedBlackList(ExecFileLog execFileLog,PageFilter pf) throws Exception {
		Grid grid = new Grid();
		List<ExecFileLog> rows = execFileLogService.queryExecFileLog(execFileLog, pf);
		Long total = execFileLogService.countExecFileLog(execFileLog);
		grid.setRows(rows);
		grid.setTotal(total);
		return grid;
	}
	
	
}
